package com.ict.txmsv2.services.impl;

import com.ict.txmsv2.dto.StudentInfoQueryDto;
import com.ict.txmsv2.model.Certificates;
import com.ict.txmsv2.mapper.CertificatesMapper;
import com.ict.txmsv2.model.CompetitionPrize;
import com.ict.txmsv2.model.RespBean;
import com.ict.txmsv2.model.RespPageBean;
import com.ict.txmsv2.services.ICertificatesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 学生考取资格证 服务实现类
 * </p>
 *
 * @author lht
 * @since 2021-04-24
 */
@Service
public class CertificatesServiceImpl extends ServiceImpl<CertificatesMapper, Certificates> implements ICertificatesService {

    @Resource
    private CertificatesMapper certificatesMapper;

    @Override
    public RespPageBean list(Integer page, Integer size, StudentInfoQueryDto queryDto) {
        if (page != null && page > 0) {
            page = (page - 1) * size;
        }
        RespPageBean resp = new RespPageBean();
        List<CompetitionPrize> list = certificatesMapper.list(page, size, queryDto);
        resp.setData(list);
        resp.setTotal(certificatesMapper.getTotal(queryDto));
        return resp;
    }
}
